package com.amit.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Lab15Client2 {

	public static void main(String[] args) {
		
		SessionFactory sessionfactory=ChibernateUtil.getfactory();
		Session session=sessionfactory.openSession();
		Transaction tx=session.beginTransaction();
		
		Student stu=(Student) session.load(Student.class, 1);
		System.out.println(stu.getSid()+" "+stu.getSname()+" "+stu.getEmail()+" "+stu.getPhone());
		
		Address add=stu.getAddress();
		
		System.out.println(add.getAdid()+" "+add.getStreet()+" "+ add.getCity()+" "+add.getState());
		
		Address add1=(Address) session.load(Address.class, 1);
		System.out.println(add1.getAdid()+" "+add1.getStreet()+" "+ add1.getCity()+" "+add1.getState());
		
		Student stu1=add1.getStudent();
		System.out.println(stu1.getSid()+" "+stu1.getSname()+" "+stu1.getEmail()+" "+stu1.getPhone());
		
		tx.commit();
	    session.close();
		
	
	}

}
